package com.cqq.print.base.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqq.common.core.bean.PageInfoBean;
import com.cqq.print.base.dao.PProducePlanDao;
import com.cqq.print.base.dao.domain.PProducePlan;
import com.cqq.print.base.service.bean.PProducePlanBean;


/**
 * @author generated
 * @date 2015-07-01
 */


@Service(value="pProducePlanService")
public class PProducePlanServiceImpl implements com.cqq.print.base.service.PProducePlanService{

             @Autowired
             private PProducePlanDao pProducePlanDao;

			
			public List<PProducePlanBean> queryAll() {
				List<PProducePlanBean> listPPPBean = null;
				List<PProducePlan> listPPP = pProducePlanDao.queryAll();
				if(listPPP!=null&&listPPP.size()>0){
					listPPPBean = new ArrayList<PProducePlanBean>();
					for (PProducePlan ppp : listPPP) {
						PProducePlanBean pppBean = new PProducePlanBean();
						BeanUtils.copyProperties(ppp, pppBean);
						listPPPBean.add(pppBean);
					}
				}
				return listPPPBean;
			}

			
			public PProducePlanBean findProPlanById(Integer id) {
				if(id==null||id<=0)
					return null;
				PProducePlan ppp = pProducePlanDao.findProPlanById(id);
				PProducePlanBean pppBean = new PProducePlanBean();
				BeanUtils.copyProperties(ppp, pppBean);
				return pppBean;
			}

			
			public int insertSelective(PProducePlanBean producePlanBean) {
				if(producePlanBean==null)
				return 0;
				PProducePlan record = new PProducePlan();
				BeanUtils.copyProperties(producePlanBean, record);
				return pProducePlanDao.insertSelective(record);
			}

			
			public PageInfoBean<PProducePlanBean> queryPProducePlanByPage(
					Map<String, Object> map) {
				List<PProducePlanBean> listPPPBean = null;
				int count = pProducePlanDao.queryCountPProducePlanByPage(map);
				List<PProducePlan> listPPP = pProducePlanDao.queryPProducePlanByPage(map);
				if(listPPP!=null&&listPPP.size()>0){
					listPPPBean = new ArrayList<PProducePlanBean>();
					for (PProducePlan ppp : listPPP) {
						PProducePlanBean pppBean = new PProducePlanBean();
						BeanUtils.copyProperties(ppp, pppBean);
						listPPPBean.add(pppBean);
					}
				}
				return new PageInfoBean<PProducePlanBean>(listPPPBean, count);
			}

			
			public int updateBySelective(PProducePlanBean producePlanBean) {
				if(producePlanBean==null||producePlanBean.getId()==null||producePlanBean.getId()<=0)
					return 0;
				PProducePlan record = new PProducePlan();
				BeanUtils.copyProperties(producePlanBean, record);
				return pProducePlanDao.updateBySelective(record);
			}

			
			public List<PProducePlanBean> queryPProducePlanBeanByIds(
					Integer[] proIds) {
				if(proIds==null||proIds.length<1)
					return null;
				String temp="";
				for (Integer planId : proIds) {
					temp=temp+","+planId;
				}
				temp ="{"+temp.substring(1)+"}";
				List<PProducePlan> listPlan = pProducePlanDao.queryPProducePlanByIds(temp);
				List<PProducePlanBean> list = null;
				if(listPlan==null || listPlan.size()<1)
					return null;
				for (PProducePlan plan : listPlan) {
					list = new ArrayList<PProducePlanBean>();
					PProducePlanBean bean = new PProducePlanBean();
					BeanUtils.copyProperties(plan, bean);
					list.add(bean);
				}
				return list;
			}

			
			public List<PProducePlanBean> queryByType(Integer type) {
				if(type==null)
					return null;
				List<PProducePlanBean> listPPPBean = null;
				List<PProducePlan> listPPP = pProducePlanDao.queryByType(type);
				if(listPPP!=null&&listPPP.size()>0){
					listPPPBean = new ArrayList<PProducePlanBean>();
					for (PProducePlan ppp : listPPP) {
						PProducePlanBean pppBean = new PProducePlanBean();
						BeanUtils.copyProperties(ppp, pppBean);
						listPPPBean.add(pppBean);
					}
				}
				return listPPPBean;
			}

}